package oa.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import oa.bean.TSystem;
import oa.service.UserService;
import oa.util.SpringUtil;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class SessionInterceptor extends HandlerInterceptorAdapter {

	private TSystem syscfg = null;
	
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		System.out.println("session interceptor");
		if(syscfg == null) {
			UserService userService = SpringUtil.getBean("userService", UserService.class);
			syscfg = userService.getsystem();
		}
		request.setAttribute("syscfg", syscfg);
		return true;
	}

}
